<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<jsp:useBean id="db" class="ctm.javacode.dbBean"/>
<%@ page import ="java.sql.*" %>
<%@ page import="java.util.ArrayList"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>中醫體質評量系統</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script language="Javascript" type="text/javascript" src="./JQuery/checkID.js"></script>
<script language="Javascript" type="text/javascript" src="./JQuery/caseHistory.js"></script>  
<script language="Javascript" type="text/javascript">
var name;
var div;
//str為顯示年份下拉選單的id,divName為顯示"始於年份:"的id
function display(str,divName,checkName)
{
name = str;
div = divName;
//如果使用者又勾選取消,則把年份下拉選單再關閉
if(!document.getElementById(checkName).checked){
	document.getElementById(name).className = "off";
	document.getElementById(div).className = "off";
	return;
}
/*document.getElementById(name).className = "on"; 
document.getElementById(div).className = "on special";
sel = document.getElementById(name);
var length=0;
var date = new Date();
for(var i=1945;i<2013;i++){
	sel.options[length] = new Option(i,i);
	if(i == date.getFullYear()){
		sel.options[length].selected=true;
	}
	length++;
}
*/
return;
}

function check() {
	var personId = document.getElementById("personId").value;
	if (personId == ""){
		alert("你未填寫身分證字號!");
		return;
	}else{
		if(checkID(personId)){
			document.getElementById("personId").value = personId;
			document.caseform.submit();	
		}		
		else{
			document.getElementById("personId").value = "";
			ClearStatus();
			return;
		}
	} 	
}
</script>
<style type="text/css">
<!--
body {
	background-image: url(img/grass.jpg);
    background-position: center top;
	background-color: #FFFFFF;
	background-repeat: repeat;
}
body,td,th {
	color: #000000;
	font-size:24px;
	font-family: Arial;
}


a:link {
font-family:Arial; 
	font-size:25px;
	text-decoration:none;
	color: #1B4001;
	background-color:#FFFFFF;
}
a:visited {
	font-family:Arial; 
	font-size:25px;
	text-decoration:none;
	color:#1B4001;
	background-color:#FFFFFF;
}
a:hover {
font-family:Arial; 
	font-size:25px;
	text-decoration:none;
	color:#000000;
	background-color:#FFFFFF;
}
  .off { display:none }
  .on  { display:inline}
.special{font-family:"標楷體"; font-size:20px;}
.tr { border-bottom:1px}

.ind:link {
	color: #FFFFFF;
	text-decoration:none;
	font-family:"Arial";
	font-size:20px;
	background-color: #437A27;
}
.ind:visited {
color:#FFFFFF;
text-decoration:none;
font-family:"Arial";
font-size:20px;
background-color: #437A27;
}

.ind:hover {
color:#000000;
text-decoration:none;
font-family:"Arial";
font-size:20px;
background-color: #437A27;
}

.HEAD_STYLE {
	font-weight:bold;
	color: #1B4001;
	font-family:"標楷體";
	font-size:30px; 
}
.TEXT_STYLE {
	font-family:"標楷體";
	color:#193940;
	font-size:30px;
	font-weight:bold;
}
.BOTTOM_STYLE {
	color: #FFFFFF; 
	font-family: Arial; 
	font-size:20px;
}
.LEFT_BUTTON {
	font-family:"標楷體"; 
	font-size:30px;
}
.button
{
	border:1px;
	padding-top: 4px;
	padding-right: 7px;
	padding-bottom: 4px;
	padding-left: 7px;
	background-color: #468129;
	color: #FFFFFF;
	font-size: 16px;
	border-color: #3C7023;
}

-->
</style>

</head>
<body alink="#FF0000" vlink="#FF0000">
<%
	db.setDataSource("jdbc/ctmpllab");
	db.Connected();
	String ac = (String)request.getSession().getAttribute("login");
	String diseas = "正常人狀態";
	String account = "select account from casehistorytable";
	ResultSet rss = db.ExcuteQuery(account);
	boolean account_confirm = false;
	int dataRow = 0;
	while(rss.next()){ // 帳戶的確認是否有資料
		if (rss.getString("account").contains(ac)) {
	account_confirm = true;
	dataRow=rss.getRow();// 取得帳戶資料的Row
	break;
		}
	}
	// 檢查身分是否已填入病例
	if (account_confirm) {
		String sqlQuery_getCaseHistory = "select history from casehistorytable";
		ResultSet rs = db.ExcuteQuery(sqlQuery_getCaseHistory);
		rs.absolute(dataRow);// 指定疾病的Row欄位
		if (!(rs.getString("history").equals("")))// 疾病欄位為空的
			diseas = rs.getString("history");
	}
	db.CloseConn();
%>
<span class="off" id="diseas"><% out.print(diseas);%></span>

<table width="100%" border="0">
		<tr>
			<td><p>&nbsp;</p></td>
		</tr>
				
			
			
		
 
    		<td width="5%">&nbsp;</td>
			
			<td bgcolor="#FFFFFF"><table width="100%" border="0">
      			<tr>
        			<td background="img/herbal.jpg">
						<p>&nbsp;</p>
          				<p>&nbsp;</p>
          				<p>&nbsp;</p>
          				<p>&nbsp;</p>
		  				<p>&nbsp;</p>
          
          			</td>
			  </tr>
     
	 
	 
	 
	  			  <tr>
        			<td>	
						<table bgcolor="#437A27" width="100%" border="0">
         					 <tr>
            					<td>&nbsp;</td>
								<td width="20%" align="center"><a  class="ind" href="main.jsp" target="_parent">回到主選單</a></td>
           			 			
          			 		</tr>
        				</table>
					</td>
     			  </tr>
     			 <tr>
        				<td>
        				<center><font class="TEXT_STYLE">疾病資料</font></center>

<form id = "form1" name="caseform"  method="post" action="caseHistory.do">
<% if (request.isUserInRole("admin")|| request.isUserInRole("professional")) { %>
<br>
<center><span>身分證字號</span>&nbsp;
<input type="text" name="personId"  id="personId" value="" onchange="getcase()" maxlength="10"/>
<!--  <input type="hidden" id="temp"></input>-->
</center>
<%} %>	
<br><center><font face="標楷體">請勾選您曾經罹患的疾病</font></center><br>	
							<table align="center" bordercolor="green" cellpadding="0" cellspacing="0" rules="rows" frame="below" >
								<tr height="40" bordercolor="green"> 
									<td width="200">
										<input type="checkbox" id="C1" name="C1" value="痛風" onClick="display('year1','label1','C1')"><label>痛風</label>
									</td>
									<td width="180">
										<div id="label1" class="off">始於年份:</div>
										<select id ="year1" class="off"></select>
									</td>	
									<td width="200">
										<input type="checkbox" id="C2" name="C2" value="胃炎" onClick="display('year2','label2','C2')"><label>胃炎</label>
									</td>
									<td width="180">	
										<div id="label2" class="off">始於年份:</div>
										<select id ="year2" class="off"></select>
									</td>									
								</tr>
								<tr height="40" bordercolor="green">	
									<td width="200">
										<input type="checkbox" id="C3" name="C3" value="高血脂" onClick="display('year3','label3','C3')"><label>高血脂</label>
									</td>
									<td width="180">	
										<div id="label3" class="off">始於年份:</div>
										<select id ="year3" class="off"></select>
									</td>
									<td width="200">
										<input type="checkbox" id="C4" name="C4" value="泌尿系統結石" onClick="display('year4','label4','C4')"><label>泌尿系統結石</label>
									</td>
									<td width="180">	
										<div id="label4" class="off">始於年份:</div>
										<select id ="year4" class="off"></select>
									</td>
								</tr>
								<tr height="40" bordercolor="green">
									<td width="200">
										<input type="checkbox" id="C5" name="C5" value="中風" onClick="display('year5','label5','C5')"><label>中風</label>
									</td>
									<td width="180">	
										<div id="label5" class="off">始於年份:</div>
										<select id ="year5" class="off"></select>
									</td>
									<td width="200">
										<input type="checkbox" id="C6" name="C6" value="糖尿病" onClick="display('year6','label6','C6')"><label>糖尿病</label>
									</td>
									<td width="180"> 	
										<div id="label6" class="off">始於年份:</div>
										<select id ="year6" class="off"></select>
									</td>
								</tr>
								<tr height="40" bordercolor="green">
									<td width="200"> 	
										<input type="checkbox" id="C7" name="C7" value="肝炎" onClick="display('year7','label7','C7')"><label>肝炎</label>
									</td>
									<td width="180">	
										<div id="label7" class="off">始於年份:</div>
										<select id ="year7" class="off"></select>
									</td>
									<td width="200">	
										<input type="checkbox" id="C8" name="C8" value="甲狀腺機能亢進" onClick="display('year8','label8','C8')"><label>甲狀腺機能亢進</label>
									</td> 
									<td width="180"> 	
										<div id="label8" class="off">始於年份:</div>
										<select id ="year8" class="off"></select>
									</td>
								</tr>
								<tr height="40" bordercolor="green">
									<td width="200">
										<input type="checkbox" id="C9" name="C9" value="腎臟病" onClick="display('year9','label9','C9')"><label>腎臟病</label>
									</td>
									<td width="180">	
										<div id="label9" class="off">始於年份:</div>
										<select id ="year9" class="off"></select>
									</td>
									<td width="200">	
										<input type="checkbox" id="C10" name="C10" value="心臟病" onClick="display('year10','label10','C10')"><label>心臟病</label>
									</td>
									<td width="180">	
										<div id="label10" class="off">始於年份:</div>
										<select id ="year10" class="off"></select>
									</td>
								</tr>
								<tr height="40" bordercolor="green">
									<td width="200">	
										<input type="checkbox" id="C11" name="C11" value="蠶豆症" onClick="display('year11','label11','C11')"><label>蠶豆症</label>
									</td>
									<td width="180">	
										<div id="label11" class="off">始於年份:</div>
										<select id ="year11" class="off"></select>
									</td>
									<td width="200">	
										<input type="checkbox" id="C12" name="C12" value="膽固醇過高" onClick="display('year12','label12','C12')"><label>膽固醇過高</label>
									</td>
									<td width="180">	
										<div id="label12" class="off">始於年份:</div>
										<select id ="year12" class="off"></select>
									</td>
								</tr>
								<tr height="40" bordercolor="green">
									<td width="200">
										<input type="checkbox" id="C13" name="C13" value="肝硬化" onClick="display('year13','label13','C13')"><label>肝硬化</label>
									</td>
									<td width="180">	
										<div id="label13" class="off">始於年份:</div>
										<select id ="year13" class="off"></select>
						       		</td>
						       		<td width="200">
						       			<input type="checkbox" id="C14" name="C14" value="高血壓" onClick="display('year14','label14','C14')"><label>高血壓</label>
						       		</td>
						       		<td width="180">	
						       			<div id="label14" class="off">始於年份:</div>
										<select id ="year14" class="off"></select>
									</td>
								</tr>
								<tr height="40" bordercolor="green"> 
									<td width="200">	
										<input type="checkbox" id="C15" name="C15" value="消化性潰瘍" onClick="display('year15','label15','C15')"><label>消化性潰瘍</label>
									</td>
									<td width="180">	
										<div id="label15" class="off">始於年份:</div>
										<select id ="year15" class="off"></select>
									</td>
									<td width="200">
						       			<input type="checkbox" id="C16" name="C16" value="癌症治療中" onClick="display('year16','label16','C16')"><label>癌症治療中</label>
						       		</td>
						       		<td width="180">	
						       			<div id="label16" class="off">始於年份:</div>
										<select id ="year16" class="off"></select>
									</td>
								</tr>
								<tr height="40" bordercolor="green"> 
									<td width="200">	
										<input type="checkbox" id="C17" name="C17" value="癌症治癒" onClick="display('year17','label17','C17')"><label>癌症治癒</label>
									</td>
									<td width="180">	
										<div id="label17" class="off">始於年份:</div>
										<select id ="year17" class="off"></select>
									</td>
									<td width="200">						       			
						       		</td>
						       		<td width="180">	
									</td>
								</tr>
							</table>
							<br/>
	<% if (request.isUserInRole("user")) { %>
	<script language="Javascript" type="text/javascript">
	var diseas = document.getElementById("diseas").innerHTML;
	var diseas_temp = "";
	var checkName = "";
	diseas_temp = diseas.split(",");
	for (i in diseas_temp) {
		checkName = checkdiseas(diseas_temp[i]);
		document.getElementById(checkName).checked = true;
	}
	</script>
	<%} %>
	<input type="hidden" name="count" id="count" value="17">						
	<center>
	<% if (request.isUserInRole("admin")|| request.isUserInRole("professional")) { %>
	<input  class="button" type="button" value="送出" onclick = "check()">
	<%}else{ %>
	<input  class="button" type="submit" value="送出">
	<%} %>
	</center>
</form>	  			  
					 <tr>
      					  
   					    <td><p>&nbsp;</p></td>
  					 </tr>
	  				
					<tr>
      					  <td bgcolor="#437A27"><div align="center" class="BOTTOM_STYLE">Copyright@ITRI and CCU_PLlab</div></td>
   
			  		</tr>
    						
  	 			  
	
			</table>
		</td>
	    
		<td width="5%">&nbsp;</td>
</table>
<p>&nbsp;</p>
</body>
</html>